/*
 * @Author: Kang
 * @Date: 2021-11-23 11:19:40
 * @Last Modified by: Kang
 * @LastEditTime: 2022-07-01 15:52:40
 */
'use strict';

/**
 * @param {Egg.Application} app - egg application
 * 管理后台接口
 */
module.exports = app => {
  const { router, controller } = app;
  router.get('/', controller.home.index);

  /**
   * 用户管理接口开始
   */
  //用户接口
  router.get('/api/user/list', controller.user.index);
  router.post('/api/user', controller.user.create);
  router.put('/api/user/:id', controller.user.update);
  router.delete('/api/user/:id', controller.user.destroy);

  //登录接口
  router.post('/login/login/account', controller.login.index);
  router.get('/api/currentUsers', controller.login.currentUser);
  /**
   * 用户管理接口结束
   */
  //------------------------------------------------------------------------------------------//


  /**
   * 资讯接口开始
   */
  //新闻发布接口
  router.get('/api/news/list', controller.news.index);
  router.post('/api/news', controller.news.create);
  router.put('/api/news', controller.news.update)
  router.delete('/api/news', controller.news.destroy)
  /**
   * 资讯接口结束
   */
  //------------------------------------------------------------------------------------------//


  /**
  * 方案接口开始
  */
  router.get('/api/plan/list', controller.plan.index);
  router.post('/api/plan', controller.plan.create);
  router.put('/api/plan', controller.plan.update)
  router.delete('/api/plan', controller.plan.destroy)

  /**
   * 方案接口结束
   */


  //------------------------------------------------------------------------------------------//


  /**
  * 案例接口开始
  */
  router.get('/api/example/list', controller.example.index);
  router.post('/api/example', controller.example.create);
  router.put('/api/example', controller.example.update)
  router.delete('/api/example', controller.example.destroy)
  router.get('/api/example/top', controller.example.top)

  /**
   * 案例接口结束
   */


  //------------------------------------------------------------------------------------------//




  /**
   * 其他接口
   */
  //上传文件接口
  router.post('/api/uploadStream', controller.uploadForStream.upload);
  router.post('/api/uploadFile', controller.uploadForFile.upload);


};
